diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-11-28 15:09:04 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-28 16:21:57 +0100 |
| commit | ab81df7f3d317281a05caec18e2cfd89dc26bc7a (patch) | |
| tree | e7c8fbdd238ebf514aa00eec98434f50ed69be73 /src/pages/sujet/[slug].tsx | |
| parent | ff79add1d59375817a10331a35458cca3c419cfe (diff) | |
refactor(services): avoid nested fetchers
If we use fetchPostsCount inside fetchAllPostsSlugs, we might have
problems to test fetchAllPostsSlugs failure. So it is better to let
the consumer pass the posts count as an argument. The same applies
to thematics and topics.
Diffstat (limited to 'src/pages/sujet/[slug].tsx')
| -rw-r--r-- | src/pages/sujet/[slug].tsx | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/pages/sujet/[slug].tsx b/src/pages/sujet/[slug].tsx index aed7ea9..c63906f 100644 --- a/src/pages/sujet/[slug].tsx +++ b/src/pages/sujet/[slug].tsx @@ -231,7 +231,8 @@ export const getStaticProps: GetStaticProps<TopicPageProps> = async ({ }; export const getStaticPaths: GetStaticPaths = async () => { - const slugs = await fetchAllTopicsSlugs(); + const topicsCount = await fetchTopicsCount(); + const slugs = await fetchAllTopicsSlugs(topicsCount); const paths = slugs.map((slug) => { return { params: { slug } }; }); |
